﻿using CIS.DB;
using CIS.Web.Common;
using CIS.Web.Models;
using CIS.Web.Properties;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using static System.Net.Mime.MediaTypeNames;

namespace CIS.Web.Controllers
{
	[AllowAnonymous]
	[RoutePrefix("Utility")]
	public class UtilityController : BaseDbController
	{
		#region 验证用户名邮箱
		[HttpPost]
		public async Task<JsonResult> CheckMail(SysUserMasterModel model)
		{
			var textMail = await DbContext.SysUserMaster.AsNoTracking().FirstOrDefaultAsync(x => x.Mail == model.Mail);

			if (textMail != null)
			{
				return JsonCamelCase(Utility.CreateFailJsonResult(), JsonRequestBehavior.AllowGet);
			}

			return JsonCamelCase(Utility.CreateSuccessJsonResult(string.Empty), JsonRequestBehavior.AllowGet);
		}
		[HttpPost]
		public async Task<JsonResult> CheckUserName(SysUserMasterModel model)
		{
			var textUserName = await DbContext.SysUserMaster.AsNoTracking().FirstOrDefaultAsync(x => x.UserName == model.UserName);

			if (textUserName != null)
			{
				return JsonCamelCase(Utility.CreateFailJsonResult(), JsonRequestBehavior.AllowGet);
			}

			return JsonCamelCase(Utility.CreateSuccessJsonResult(string.Empty), JsonRequestBehavior.AllowGet);
		}
		#endregion

		#region 检索条件下拉框
		/// <summary>
		/// 专题
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetTopicWithAll(string conferenceId)
		{
			var result = await DbContext.TopicMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == conferenceId)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.TopicName)
					.Select(x => new
					{
						Id = x.ID,
						Name = x.TopicName
					})
					.ToListAsync();

			result.Insert(0, new
			{
				Id = string.Empty,
				Name = Resources.All
			});

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 论文类型
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetEssayWithAll(string conferenceId)
		{
			var result = await DbContext.EssayMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == conferenceId)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.EssayType)
					.Select(x => new
					{
						Id = x.ID,
						Name = x.EssayType
					})
					.ToListAsync();

			result.Insert(0, new
			{
				Id = string.Empty,
				Name = Resources.All
			});

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 报告类型
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetReportWithAll(string conferenceId)
		{
			var result = await DbContext.ReportMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == conferenceId)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.ReportType)
					.Select(x => new
					{
						Id = x.ID,
						Name = x.ReportType
					})
					.ToListAsync();

			result.Insert(0, new
			{
				Id = string.Empty,
				Name = Resources.All
			});

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 目标期刊
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetJournalWithAll(string conferenceId)
		{
			var result = await DbContext.JournalMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == conferenceId)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.JournalName)
					.Select(x => new
					{
						Id = x.ID,
						Name = x.JournalName
					})
					.ToListAsync();

			result.Insert(0, new
			{
				Id = string.Empty,
				Name = Resources.All
			});

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 参会身份
		/// </summary>
		public async Task<JsonResult> GetAttendenceIdentityTypeWithAll(string conferenceId)
		{
			var result = await DbContext.AttendenceIdentityMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == conferenceId)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.IdentityName)
					.Select(x => new
					{
						Id = x.ID,
						Name = x.IdentityName
					})
					.ToListAsync();

			result.Insert(0, new
			{
				Id = string.Empty,
				Name = Resources.All
			});

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 参会身份
		/// 同期活动中所有适用 zhaoyueqi
		/// </summary>
		public async Task<JsonResult> GetAttendenceIdentityTypeApplicableForAll(string conferenceId, string isAll)
		{
			if (isAll == "true")
			{
				var result = await DbContext.AttendenceIdentityMaster.AsNoTracking()
					 .Where(x => x.Status == ConstValues.Status.正常 &&
						 x.ConferenceId == conferenceId)
					 .OrderBy(x => x.Sort)
					 .ThenBy(x => x.IdentityName)
					 .ToListAsync();
				return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
			}
			else
			{
				var result = new List<AttendenceIdentityMaster>();
				result.Add(new AttendenceIdentityMaster
				{
					ID = ConstValues.ApplicableForAll,
					IdentityName = Resources.ApplicableForAll
				});
				return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
			}
		}

		/// <summary>
		/// 酒店
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetHotelWithAll(string conferenceId)
		{
			var result = await DbContext.HotelMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == conferenceId)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.HotelName)
					.Select(x => new
					{
						Id = x.ID,
						Name = x.HotelName
					})
					.ToListAsync();

			result.Insert(0, new
			{
				Id = string.Empty,
				Name = Resources.All
			});

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 职业
		/// </summary>
		public async Task<JsonResult> GetCareerWithAll()
		{
			if (Request.Cookies["_culture"] != null && Request.Cookies["_culture"].Value == ConstValues.Language.En)
			{
				var result = await DbContext.CareerMaster.AsNoTracking()
						.OrderBy(x => x.ID)
						.Select(x => new
						{
							Id = x.ID,
							Name = x.CareerNameEn
						})
						.ToListAsync();

				result.Insert(0, new
				{
					Id = 0,
					Name = Resources.All
				});

				return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
			}
			else
			{
				var result = await DbContext.CareerMaster.AsNoTracking()
						.OrderBy(x => x.ID)
						.Select(x => new
						{
							Id = x.ID,
							Name = x.CareerName
						})
						.ToListAsync();

				result.Insert(0, new
				{
					Id = 0,
					Name = Resources.All
				});

				return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
			}
		}

		/// <summary>
		/// 参会身份
		/// </summary>
		public async Task<JsonResult> GetAllAttendenceIdentityTypeWithAll()
		{
			var result = await DbContext.AttendenceIdentityMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.IdentityName)
					.Select(x => new
					{
						Name = x.IdentityName
					})
					.Distinct()
					.ToListAsync();

			result.Insert(0, new
			{
				Name = Resources.All
			});

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 交通
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetTrafficWithAll(string conferenceId)
		{
			var result = await DbContext.TrafficMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == conferenceId)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.TrafficName)
					.Select(x => new
					{
						Id = x.ID,
						Name = x.TrafficName
					})
					.ToListAsync();

			result.Insert(0, new
			{
				Id = string.Empty,
				Name = Resources.All
			});

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 支付方式
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetPayTypeWithAll(string conferenceId)
		{
			if (Request.Cookies["_culture"] != null && Request.Cookies["_culture"].Value == ConstValues.Language.En)
			{
				var result = await DbContext.ConferencePaymentMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == conferenceId)
					.Join(DbContext.SysPaymentMaster.AsNoTracking()
						.Where(x => x.Status == ConstValues.Status.正常),
						pay => pay.PayId,
						master => master.ID,
						(pay, master) => new
						{
							Id = pay.ID,
							Name = master.PaymentNameEn,
							Sort = pay.Sort ?? 0
						})
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.Name)
					.ToListAsync();

				result.Insert(0, new
				{
					Id = string.Empty,
					Name = Resources.All,
					Sort = 0
				});

				return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
			}
			else
			{
				var result = await DbContext.ConferencePaymentMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == conferenceId)
					.Join(DbContext.SysPaymentMaster.AsNoTracking()
						.Where(x => x.Status == ConstValues.Status.正常),
						pay => pay.PayId,
						master => master.ID,
						(pay, master) => new
						{
							Id = pay.ID,
							Name = master.PaymentName,
							Sort = pay.Sort ?? 0
						})
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.Name)
					.ToListAsync();

				result.Insert(0, new
				{
					Id = string.Empty,
					Name = Resources.All,
					Sort = 0
				});

				return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
			}
		}

		/// <summary>
		/// 获取发票信息
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetInvoiceInfo()
		{
			var result = await DbContext.InvoiceMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常)
					.OrderBy(x => x.InvoiceTitle)
					.ThenBy(x => x.CreateDate)
					.Select(x => new InvoiceModel()
					{
						InvoiceTitle = x.InvoiceTitle,
						TaxNum = x.TaxNum,
						AddressAndTel = x.AddressAndTel,
						Bank = x.Bank,
						BankAccount = x.BankAccount
					})
					.ToListAsync();

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}
		#endregion

		#region 中文环境英文信息下拉框
		/// <summary>
		/// 国家
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetCountryEn()
		{
			var result = await DbContext.LocationMaster.AsNoTracking()
					.Where(x => x.Level == ConstValues.LocationLevel.国家)
					.OrderBy(x => x.NameEn)
					.Select(x => new
					{
						Id = x.ID,
						Name = x.NameEn
					})
					.ToListAsync();

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 州
		/// </summary>
		public async Task<JsonResult> GetStateEn(int? id)
		{
			var result = await DbContext.LocationMaster.AsNoTracking()
					.Where(x => x.ParentId == id)
					.OrderBy(x => x.NameEn)
					.Select(x => new
					{
						Id = x.ID,
						Name = x.NameEn
					})
					.ToListAsync();

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 市
		/// </summary>
		public async Task<JsonResult> GetCityEn(int? id)
		{
			var result = await DbContext.LocationMaster.AsNoTracking()
					.Where(x => x.ParentId == id)
					.OrderBy(x => x.NameEn)
					.Select(x => new
					{
						Id = x.ID,
						Name = x.NameEn
					})
					.ToListAsync();

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 职业
		/// </summary>
		public async Task<JsonResult> GetCareerEn()
		{
			var result = await DbContext.CareerMaster.AsNoTracking()
					.OrderBy(x => x.ID)
					.Select(x => new
					{
						Id = x.ID,
						Name = x.CareerNameEn
					})
					.ToListAsync();

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 学位
		/// </summary>
		public async Task<JsonResult> GetDegreeEn()
		{
			var result = await DbContext.DegreeMaster.AsNoTracking()
					.OrderBy(x => x.ID)
					.Select(x => new
					{
						Id = x.ID,
						Name = x.DegreeNameEn
					})
					.ToListAsync();

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 系统称呼
		/// </summary>
		/// <param name="language"></param>
		/// <returns></returns>
		public async Task<JsonResult> GetCallEn(string language)
		{
			var result = await DbContext.CallMaster.AsNoTracking()
					.Where(x => language == ConstValues.Language.Cn ? !string.IsNullOrEmpty(x.CallName) : true)
					.OrderBy(x => x.ID)
					.Select(x => new
					{
						Id = x.ID,
						Name = language == ConstValues.Language.Cn ? x.CallName : x.CallNameEn
					})
					.ToListAsync();

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}
		#endregion

		#region 下拉框数据
		/// <summary>
		/// 用户
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetUser()
		{
			var result = await DbContext.SysUserMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.UserName)
					.Select(x => new
					{
						Id = x.ID,
						UserName = x.UserName,
						Mail = x.Mail
					})
					.ToListAsync();

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 用户组
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetUserGroup()
		{
			var result = await DbContext.SysUserGroupMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.UserGroupName)
					.Select(x => new
					{
						Id = x.ID,
						UserGroupName = x.UserGroupName
					})
					.ToListAsync();

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 权限
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetAction()
		{
			var result = await DbContext.SysActionMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.ActionName)
					.Select(x => new
					{
						Id = x.ID,
						ActionName = x.ActionName
					})
					.ToListAsync();

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 系统功能
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetSysFunction()
		{
			var result = await DbContext.SysFunctionMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.FunctionType == ConstValues.PageLogsType.系统)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.ID)
					.Select(x => new
					{
						Id = x.ID,
						FunctionName = x.FunctionName
					})
					.ToListAsync();

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 会议功能
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetConferenceFunction()
		{
			if (Request.Cookies["_culture"] != null && Request.Cookies["_culture"].Value == ConstValues.Language.En)
			{
				var result = await DbContext.SysFunctionMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.FunctionType == ConstValues.PageLogsType.会议)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.FunctionName)
					.Select(x => new
					{
						Id = x.ID,
						FunctionName = x.Remark
					})
					.ToListAsync();

				return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
			}
			else
			{
				var result = await DbContext.SysFunctionMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.FunctionType == ConstValues.PageLogsType.会议)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.FunctionName)
					.Select(x => new
					{
						Id = x.ID,
						FunctionName = x.FunctionName
					})
					.ToListAsync();

				return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
			}
		}

		/// <summary>
		/// 国家
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetCountry()
		{
			if (Request.Cookies["_culture"] != null && Request.Cookies["_culture"].Value == ConstValues.Language.En)
			{
				var result = await DbContext.LocationMaster.AsNoTracking()
						.Where(x => x.Level == ConstValues.LocationLevel.国家)
						.OrderBy(x => x.NameEn)
						.Select(x => new
						{
							Id = x.ID,
							Name = x.NameEn
						})
						.ToListAsync();

				return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
			}
			else
			{
				var result = await DbContext.LocationMaster.AsNoTracking()
						.Where(x => x.Level == ConstValues.LocationLevel.国家)
						.OrderBy(x => x.Name)
						.Select(x => new
						{
							Id = x.ID,
							Name = x.Name
						})
						.ToListAsync();

				return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
			}
		}

		/// <summary>
		/// 州
		/// </summary>
		public async Task<JsonResult> GetState(int? id)
		{
			if (Request.Cookies["_culture"] != null && Request.Cookies["_culture"].Value == ConstValues.Language.En)
			{
				var result = await DbContext.LocationMaster.AsNoTracking()
						.Where(x => x.Level == ConstValues.LocationLevel.州 &&
							x.ParentId == id)
						.OrderBy(x => x.NameEn)
						.Select(x => new
						{
							Id = x.ID,
							Name = x.NameEn
						})
						.ToListAsync();

				return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
			}
			else
			{
				var result = await DbContext.LocationMaster.AsNoTracking()
						.Where(x => x.Level == ConstValues.LocationLevel.州 &&
							x.ParentId == id)
						.OrderBy(x => x.Name)
						.Select(x => new
						{
							Id = x.ID,
							Name = x.Name
						})
						.ToListAsync();

				return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
			}
		}

		/// <summary>
		/// 市
		/// </summary>
		public async Task<JsonResult> GetCity(int? id)
		{
			if (Request.Cookies["_culture"] != null && Request.Cookies["_culture"].Value == ConstValues.Language.En)
			{
				var result = await DbContext.LocationMaster.AsNoTracking()
						.Where(x => x.Level == ConstValues.LocationLevel.市 &&
							x.ParentId == id)
						.OrderBy(x => x.NameEn)
						.Select(x => new
						{
							Id = x.ID,
							Name = x.NameEn
						})
						.ToListAsync();

				return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
			}
			else
			{
				var result = await DbContext.LocationMaster.AsNoTracking()
						.Where(x => x.Level == ConstValues.LocationLevel.市 &&
							x.ParentId == id)
						.OrderBy(x => x.Name)
						.Select(x => new
						{
							Id = x.ID,
							Name = x.Name
						})
						.ToListAsync();

				return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
			}
		}

		/// <summary>
		/// 职业
		/// </summary>
		public async Task<JsonResult> GetCareer()
		{
			if (Request.Cookies["_culture"] != null && Request.Cookies["_culture"].Value == ConstValues.Language.En)
			{
				var result = await DbContext.CareerMaster.AsNoTracking()
						.OrderBy(x => x.ID)
						.Select(x => new
						{
							Id = x.ID,
							Name = x.CareerNameEn
						})
						.ToListAsync();

				return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
			}
			else
			{
				var result = await DbContext.CareerMaster.AsNoTracking()
						.OrderBy(x => x.ID)
						.Select(x => new
						{
							Id = x.ID,
							Name = x.CareerName
						})
						.ToListAsync();

				return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
			}
		}

		/// <summary>
		/// 学位
		/// </summary>
		public async Task<JsonResult> GetDegree()
		{
			if (Request.Cookies["_culture"] != null && Request.Cookies["_culture"].Value == ConstValues.Language.En)
			{
				var result = await DbContext.DegreeMaster.AsNoTracking()
						.OrderBy(x => x.ID)
						.Select(x => new
						{
							Id = x.ID,
							Name = x.DegreeNameEn
						})
						.ToListAsync();

				return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
			}
			else
			{
				var result = await DbContext.DegreeMaster.AsNoTracking()
						.OrderBy(x => x.ID)
						.Select(x => new
						{
							Id = x.ID,
							Name = x.DegreeName
						})
						.ToListAsync();

				return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
			}
		}

		/// <summary>
		/// 系统称呼
		/// </summary>
		public async Task<JsonResult> GetCall()
		{
			if (Request.Cookies["_culture"] != null && Request.Cookies["_culture"].Value == ConstValues.Language.En)
			{
				var result = await DbContext.CallMaster.AsNoTracking()
						.OrderBy(x => x.ID)
						.Select(x => new
						{
							Id = x.ID,
							Name = x.CallNameEn
						})
						.ToListAsync();

				return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
			}
			else
			{
				var result = await DbContext.CallMaster.AsNoTracking()
						.Where(x => !string.IsNullOrEmpty(x.CallName))
						.OrderBy(x => x.ID)
						.Select(x => new
						{
							Id = x.ID,
							Name = x.CallName
						})
						.ToListAsync();

				return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
			}
		}

		/// <summary>
		/// 会议
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetConference()
		{
			var result = await DbContext.ConferenceMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.ConferenceName)
					.Select(x => new
					{
						Id = x.ID,
						Name = x.ConferenceName
					})
					.ToListAsync();

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 参会投稿
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetContribute()
		{
			if (Request.Cookies["_culture"].Value == ConstValues.Language.Cn)
			{
				var result = await DbContext.ContributeMaster.AsNoTracking()
						.Where(x => x.Status == ConstValues.Status.正常)
						.OrderBy(x => x.DisplayPage)
						.ThenBy(x => x.Sort)
						.Select(x => new
						{
							Id = x.ID,
							Key = x.Key,
							DisplayName = x.DisplayName,
							Tip = x.Tip,
							DisplayPage = x.DisplayPage,
							IsRequired = x.IsRequired,
							Status = x.Status,
							Sort = x.Sort
						})
						.ToListAsync();

				return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
			}
			else
			{
				var result = await DbContext.ContributeMaster.AsNoTracking()
						.Where(x => x.Status == ConstValues.Status.正常)
						.OrderBy(x => x.DisplayPage)
						.ThenBy(x => x.Sort)
						.Select(x => new
						{
							Id = x.ID,
							Key = x.Key,
							DisplayName = x.Key,
							Tip = x.Tip,
							DisplayPage = x.DisplayPage,
							IsRequired = x.IsRequired,
							Status = x.Status,
							Sort = x.Sort
						})
						.ToListAsync();

				return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
			}
		}

		/// <summary>
		/// 参会注册
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetAttendence()
		{
			if (Request.Cookies["_culture"].Value == ConstValues.Language.Cn)
			{
				var result = await DbContext.AttendenceMaster.AsNoTracking()
						.Where(x => x.Status == ConstValues.Status.正常)
						.OrderBy(x => x.DisplayPage)
						.ThenBy(x => x.Sort)
						.Select(x => new
						{
							Id = x.ID,
							Key = x.Key,
							DisplayName = x.DisplayName,
							Tip = x.Tip,
							DisplayPage = x.DisplayPage,
							IsRequired = x.IsRequired,
							Status = x.Status,
							Sort = x.Sort
						})
						.ToListAsync();

				return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
			}
			else
			{
				var result = await DbContext.AttendenceMaster.AsNoTracking()
						.Where(x => x.Status == ConstValues.Status.正常)
						.OrderBy(x => x.DisplayPage)
						.ThenBy(x => x.Sort)
						.Select(x => new
						{
							Id = x.ID,
							Key = x.Key,
							DisplayName = x.Key,
							Tip = x.Tip,
							DisplayPage = x.DisplayPage,
							IsRequired = x.IsRequired,
							Status = x.Status,
							Sort = x.Sort
						})
						.ToListAsync();

				return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
			}
		}

		/// <summary>
		/// OCIS
		/// </summary>
		public async Task<JsonResult> GetOCIS(string conferenceId)
		{
			var result = await DbContext.OCISMaster.AsNoTracking()
					.Where(x => x.ConferenceId == conferenceId && x.Status == ConstValues.Status.正常)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.OCISName)
					.Select(x => new
					{
						Id = x.ID,
						Name = x.OCISName
					})
					.ToListAsync();

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 支付方式
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetPayType(string conferenceId)
		{
			if (Request.Cookies["_culture"] != null && Request.Cookies["_culture"].Value == ConstValues.Language.En)
			{
				var result = await DbContext.ConferencePaymentMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == conferenceId)
					.Join(DbContext.SysPaymentMaster.AsNoTracking()
						.Where(x => x.Status == ConstValues.Status.正常),
						pay => pay.PayId,
						master => master.ID,
						(pay, master) => new
						{
							Id = pay.ID,
							Name = master.PaymentNameEn,
							Sort = pay.Sort
						})
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.Name)
					.ToListAsync();
				return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
			}
			else
			{
				var result = await DbContext.ConferencePaymentMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == conferenceId)
					.Join(DbContext.SysPaymentMaster.AsNoTracking()
						.Where(x => x.Status == ConstValues.Status.正常),
						pay => pay.PayId,
						master => master.ID,
						(pay, master) => new
						{
							Id = pay.ID,
							Name = master.PaymentName,
							Sort = pay.Sort
						})
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.Name)
					.ToListAsync();
				return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
			}
		}

		/// <summary>
		/// 网上支付方式
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetOnlinePayType(string conferenceId)
		{
			if (Request.Cookies["_culture"] != null && Request.Cookies["_culture"].Value == ConstValues.Language.En)
			{
				var result = await DbContext.ConferencePaymentMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == conferenceId)
					.Join(DbContext.SysPaymentMaster.AsNoTracking()
						.Where(x => x.Status == ConstValues.Status.正常 && x.IsOnline.Value == true),
						pay => pay.PayId,
						master => master.ID,
						(pay, master) => new
						{
							Id = pay.ID,
							Name = master.PaymentNameEn,
							Sort = pay.Sort
						})
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.Name)
					.ToListAsync();
				return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
			}
			else
			{
				var result = await DbContext.ConferencePaymentMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == conferenceId)
					.Join(DbContext.SysPaymentMaster.AsNoTracking()
						.Where(x => x.Status == ConstValues.Status.正常 && x.IsOnline.Value == true),
						pay => pay.PayId,
						master => master.ID,
						(pay, master) => new
						{
							Id = pay.ID,
							Name = master.PaymentName,
							Sort = pay.Sort
						})
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.Name)
					.ToListAsync();
				return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
			}
		}

		/// <summary>
		/// 线下支付方式
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetPhysicalPayType(string conferenceId)
		{
			if (Request.Cookies["_culture"] != null && Request.Cookies["_culture"].Value == ConstValues.Language.En)
			{
				var result = await DbContext.ConferencePaymentMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == conferenceId)
					.Join(DbContext.SysPaymentMaster.AsNoTracking()
						.Where(x => x.Status == ConstValues.Status.正常),
						pay => pay.PayId,
						master => master.ID,
						(pay, master) => new
						{
							Id = pay.ID,
							Name = master.PaymentNameEn,
							Sort = pay.Sort
						})
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.Name)
					.ToListAsync();
				return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
			}
			else
			{
				var result = await DbContext.ConferencePaymentMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == conferenceId)
					.Join(DbContext.SysPaymentMaster.AsNoTracking()
						.Where(x => x.Status == ConstValues.Status.正常),
						pay => pay.PayId,
						master => master.ID,
						(pay, master) => new
						{
							Id = pay.ID,
							Name = master.PaymentName,
							Sort = pay.Sort
						})
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.Name)
					.ToListAsync();
				return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
			}
		}

		/// <summary>
		/// 参会身份
		/// </summary>
		public async Task<JsonResult> GetAttendenceIdentityType(string conferenceId)
		{
			var result = await DbContext.AttendenceIdentityMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == conferenceId)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.IdentityName)
					.Select(x => new
					{
						Id = x.ID,
						Name = x.IdentityName
					})
					.ToListAsync();

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 称呼
		/// </summary>
		public async Task<JsonResult> GetTitle(string conferenceId)
		{
			var result = await DbContext.TitleMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == conferenceId)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.TitleName)
					.Select(x => new
					{
						Id = x.ID,
						Name = x.TitleName
					})
					.ToListAsync();

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 专题
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetTopic(string conferenceId)
		{
			var result = await DbContext.TopicMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == conferenceId)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.TopicName)
					.Select(x => new
					{
						Id = x.ID,
						Name = x.TopicName
					})
					.ToListAsync();

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 论文类型
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetEssay(string conferenceId)
		{
			var result = await DbContext.EssayMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == conferenceId)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.EssayType)
					.Select(x => new
					{
						Id = x.ID,
						Name = x.EssayType
					})
					.ToListAsync();

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 报告类型
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetReport(string conferenceId)
		{
			var result = await DbContext.ReportMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == conferenceId)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.ReportType)
					.Select(x => new
					{
						Id = x.ID,
						Name = x.ReportType
					})
					.ToListAsync();

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 目标期刊
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetJournal(string conferenceId)
		{
			var result = await DbContext.JournalMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == conferenceId)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.JournalName)
					.Select(x => new
					{
						Id = x.ID,
						Name = x.JournalName
					})
					.ToListAsync();

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 论文题目
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetEssayTitle(string conferenceId, string userName)
		{
			var result = await DbContext.ConferenceContributeInfo.AsNoTracking()
					.Where(x => x.ConferenceId == conferenceId &&
						(!string.IsNullOrEmpty(x.AdminStatus) ? x.AdminStatus == ConstValues.ContributationStatus.不录用 :
							x.ContributationStatus == ConstValues.ContributationStatus.不录用) &&
						x.Creator == userName)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.EssayTitle)
					.Select(x => new
					{
						Id = x.ID,
						Name = x.EssayTitle
					})
					.ToListAsync();

			result.Insert(0, new
			{
				Id = ConstValues.DefaultEmpty,
				Name = ConstValues.DefaultEmpty
			});

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 论文题目 && 审稿专家数
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetEssayTitleWithReviewCount(string conferenceId)
		{
			var result = await DbContext.ConferenceContributeInfo.AsNoTracking()
						.Where(x => x.ConferenceId == conferenceId &&
							x.ContributationStatus == ConstValues.ContributationStatus.待审)
						.OrderBy(x => x.Sort)
						.ThenBy(x => x.EssayTitle)
						.Select(x => new EssayCountModel
						{
							Id = x.ID,
							Name = x.EssayTitle
						})
						.ToListAsync();

			result.ForEach(x =>
			{
				x.ReviewCount = DbContext.ReviewInfo.AsNoTracking().Count(y => y.ContributeId == x.Id);
			});

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 发票明细
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetInvoiceTitle(string conferenceId)
		{
			var result = await DbContext.ConferenceInvoiceMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == conferenceId)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.InvoiceDetail)
					.Select(x => new
					{
						Id = x.ID,
						Name = x.InvoiceDetail
					})
					.ToListAsync();

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 版面费
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetFeePage(string conferenceId, string currency)
		{
			var result = await DbContext.FeePageMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == conferenceId &&
						x.Currency == currency)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.FeeName)
					.Select(x => new
					{
						Id = x.ID,
						Name = x.FeeName,
						Price = x.Price,
						Currency = x.Currency
					})
					.ToListAsync();

			var newResult = result.Select(x => new
			{
				Id = x.Id,
				Name = x.Name,
				Price = x.Price,
				Currency = x.Currency,
				NameAndPrice = x.Name + ConstValues.chrSpace + ConstValues.strLeftBracket + x.Currency +
						ConstValues.chrSpace + x.Price.Value.ToString("N2") + ConstValues.strRightBracket
			});

			return JsonCamelCase(newResult, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 参会费
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetFeeAttendence(string conferenceId, string currency)
		{
			var conferenceMaster = DbContext.ConferenceMaster.AsNoTracking().FirstOrDefault(x => x.ID == conferenceId);
			var isBenefit = false;
			if (conferenceMaster.BenefitStartDate <= DateTime.Now && DateTime.Now <= conferenceMaster.BenefitEndDate)
			{
				isBenefit = true;
			}

			var result = await DbContext.FeeAttendenceMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == conferenceId &&
						x.Currency == currency)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.RegisterType)
					.Select(x => new
					{
						Id = x.ID,
						Name = x.RegisterType,
						Price = x.Price,
						Currency = x.Currency,
						Discount = x.Discount,
						Sort = x.Sort
					})
					.ToListAsync();

			var newResult = result.Select(x => new
			{
				Id = x.Id,
				Name = x.Name,
				Price = x.Price,
				Currency = x.Currency,
				Discount = x.Discount,
				Sort = x.Sort,
				NameAndPrice = isBenefit ? x.Name + ConstValues.chrSpace + ConstValues.strLeftBracket + x.Currency +
						ConstValues.chrSpace + x.Discount.Value.ToString("N2") + ConstValues.strRightBracket :
						x.Name + ConstValues.chrSpace + ConstValues.strLeftBracket + x.Currency +
						ConstValues.chrSpace + x.Price.Value.ToString("N2") + ConstValues.strRightBracket
			});

			return JsonCamelCase(newResult, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 餐费
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetFeeMeal(string conferenceId, string currency)
		{
			var result = await DbContext.FeeMealMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == conferenceId &&
						x.Currency == currency)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.FeeName)
					.Select(x => new
					{
						Id = x.ID,
						Name = x.FeeName,
						Price = x.Price,
						Currency = x.Currency,
						Count = x.Count
					})
					.ToListAsync();
			var newResult = result.Select(x => new
			{
				Id = x.Id,
				Name = x.Name,
				Price = x.Price,
				Currency = x.Currency,
				Count = x.Count,
				NameAndPrice = x.Name + ConstValues.chrSpace + ConstValues.strLeftBracket + x.Currency +
						ConstValues.chrSpace + x.Price.Value.ToString("N2") + ConstValues.strRightBracket
			});

			return JsonCamelCase(newResult, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 其他费用
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetFeeOther(string conferenceId, string currency)
		{
			var result = await DbContext.FeeOtherMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == conferenceId &&
						x.Currency == currency &&
						(x.Deadline.HasValue ? x.Deadline.Value > DateTime.Now : true))
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.FeeName)
					.Select(x => new
					{
						Id = x.ID,
						Name = x.FeeName,
						MinCount = x.MinCount,
						MaxCount = x.MaxCount,
						Price = x.Price,
						Currency = x.Currency,
						Deadline = x.Deadline,
						Recommendation = x.Recommendation
					})
					.ToListAsync();

			var newResult = result.Select(x => new
			{
				Id = x.Id,
				Name = x.Name,
				MinCount = x.MinCount,
				MaxCount = x.MaxCount,
				Price = x.Price,
				Currency = x.Currency,
				Deadline = x.Deadline,
				NameAndPrice = x.Name + ConstValues.chrSpace + ConstValues.strLeftBracket + x.Currency +
						ConstValues.chrSpace + x.Price.Value.ToString("N2") + ConstValues.strRightBracket
			});

			return JsonCamelCase(newResult, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 其他费用数量
		/// </summary>
		/// <returns></returns>
		public JsonResult GetFeeOtherCount(int minCount, int maxCount)
		{
			var result = new List<int>();

			for (int index = minCount; index <= maxCount; index++)
			{
				result.Add(index);
			}

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 酒店
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetHotel(string conferenceId)
		{
			var result = await DbContext.HotelMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == conferenceId)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.HotelName)
					.Select(x => new
					{
						Id = x.ID,
						Name = x.HotelName,
						HotelAddress = x.HotelAddress,
						HotelTel = x.HotelTel,
						Level = x.Level,
						ParkingFee = x.ParkingFee,
						LeftRoomCount = x.LeftRoomCount,
						LeftBedCount = x.LeftBedCount
					})
					.ToListAsync();

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 房间
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetRoom(string hotelId, string currency)
		{
			var result = await DbContext.RoomMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.HotelId == hotelId &&
						x.Currency == currency)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.RoomType)
					.Select(x => new
					{
						Id = x.ID,
						Name = x.RoomType,
						RoomBedCount = x.RoomBedCount,
						Price1 = x.Price1,
						Price2 = x.Price2,
						Currency = x.Currency,
						LeftRoomCount = x.LeftRoomCount,
						LeftBedCount = x.LeftBedCount
					})
					.ToListAsync();

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 取不同的房型
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetDistinctRoom(string hotelId, string currency)
		{
			var result = await DbContext.RoomMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.HotelId == hotelId &&
						x.Currency == currency)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.RoomType)
					.GroupBy(x => x.RoomType)
					.Select(x => new
					{
						Id = x.Key,
						Name = x.Key,
						Currency = x.Max(y => y.Currency),
						Price1 = x.Max(y => y.Price1),
						Price2 = x.Max(y => y.Price2),
					})
					.ToListAsync();

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 问卷
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetQuiz(string conferenceId)
		{
			var result = await DbContext.QuizMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == conferenceId)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.QuizName)
					.Select(x => new
					{
						Id = x.ID,
						Name = x.QuizName
					})
					.ToListAsync();

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 会场出席情况
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetAttendenceInfoType(string conferenceId)
		{
			var conferenceMaster = await DbContext.ConferenceMaster.AsNoTracking().FirstOrDefaultAsync(x => x.ID == conferenceId);
			List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
			if (!conferenceMaster.IsInternational)
			{
				Dictionary<string, string> map = new Dictionary<string, string>();
				map.Add("Id", ConstValues.AttendenceInfoType.本人出席);
				map.Add("Name", ConstValues.AttendenceInfoType.本人出席);
				list.Add(map);

				Dictionary<string, string> map2 = new Dictionary<string, string>();
				map2.Add("Id", ConstValues.AttendenceInfoType.他人代讲);
				map2.Add("Name", ConstValues.AttendenceInfoType.他人代讲);
				list.Add(map2);

				Dictionary<string, string> map3 = new Dictionary<string, string>();
				map3.Add("Id", ConstValues.AttendenceInfoType.未出席);
				map3.Add("Name", ConstValues.AttendenceInfoType.未出席);
				list.Add(map3);

				Dictionary<string, string> map4 = new Dictionary<string, string>();
				map4.Add("Id", ConstValues.AttendenceInfoType.其他);
				map4.Add("Name", ConstValues.AttendenceInfoType.其他);
				list.Add(map4);
			}
			else
			{
				Dictionary<string, string> map = new Dictionary<string, string>();
				map.Add("Id", ConstValues.AttendenceInfoType.本人出席);
				map.Add("Name", ConstValues.AttendenceInfoTypeEn.本人出席);
				list.Add(map);

				Dictionary<string, string> map2 = new Dictionary<string, string>();
				map2.Add("Id", ConstValues.AttendenceInfoType.他人代讲);
				map2.Add("Name", ConstValues.AttendenceInfoTypeEn.他人代讲);
				list.Add(map2);

				Dictionary<string, string> map3 = new Dictionary<string, string>();
				map3.Add("Id", ConstValues.AttendenceInfoType.未出席);
				map3.Add("Name", ConstValues.AttendenceInfoTypeEn.未出席);
				list.Add(map3);

				Dictionary<string, string> map4 = new Dictionary<string, string>();
				map4.Add("Id", ConstValues.AttendenceInfoType.其他);
				map4.Add("Name", ConstValues.AttendenceInfoTypeEn.其他);
				list.Add(map4);
			}

			return JsonCamelCase(list, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 消息分类
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetNewsList(string conferenceId)
		{
			var result = await DbContext.NewsListInfo.AsNoTracking()
				.Where(x => x.Status == ConstValues.Status.正常 &&
				    x.ConferenceId == conferenceId)
				.OrderBy(x => x.Sort)
				.ThenBy(x => x.NewsListName)
				.Select(x => new
				{
					Id = x.ID,
					Name = x.NewsListName
				})
				.ToListAsync();

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 会议模板
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> GetConferenceModel()
		{
			if (Request.Cookies["_culture"] != null && Request.Cookies["_culture"].Value == ConstValues.Language.En)
			{
				var result = await DbContext.SysConferenceModelMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.ModelKey)
					.Select(x => new
					{
						Id = x.ModelKey,
						Name = x.ModelNameEn
					})
					.ToListAsync();

				return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
			}
			else
			{
				var result = await DbContext.SysConferenceModelMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.ModelKey)
					.Select(x => new
					{
						Id = x.ModelKey,
						Name = x.ModelName
					})
					.ToListAsync();

				return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
			}
		}

		/// <summary>
		/// 会议周期
		/// </summary>
		public async Task<JsonResult> GetConferenceDate(string conferenceId)
		{
			var sqlResult = await DbContext.ConferenceMaster.AsNoTracking()
					.FirstOrDefaultAsync(x => x.ID == conferenceId && x.Status == ConstValues.Status.正常);

			var result = new List<ConferenceScheduleDateModel>();
			var index = 0;
			while (sqlResult.ConferenceStartDate.Value.AddDays(index) <= sqlResult.ConferenceEndDate.Value)
			{
				result.Add(new ConferenceScheduleDateModel
				{
					Id = sqlResult.IsInternational == false ?
						sqlResult.ConferenceStartDate.Value.AddDays(index).ToString("yyyy-MM-dd") :
						sqlResult.ConferenceStartDate.Value.AddDays(index).ToString("MM/dd/yyyy"),
					ScheduleDate = sqlResult.ConferenceStartDate.Value.AddDays(index)
				});
				index++;
			}

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 酒店入住周期
		/// </summary>
		public async Task<JsonResult> GetConferenceCheckinDate(string conferenceId)
		{
			var sqlResult = await DbContext.ConferenceMaster.AsNoTracking()
					.FirstOrDefaultAsync(x => x.ID == conferenceId && x.Status == ConstValues.Status.正常);

			var result = new List<HotelCheckinModel>();

			var index = 0;
			while (sqlResult.CheckinDate.Value.AddDays(index) <= sqlResult.CheckoutDate.Value)
			{
				result.Add(new HotelCheckinModel
				{
					Id = sqlResult.IsInternational == false ?
						sqlResult.CheckinDate.Value.AddDays(index).ToString("yyyy-MM-dd") :
						sqlResult.CheckinDate.Value.AddDays(index).ToString("MM/dd/yyyy"),
					CheckinDate = sqlResult.CheckinDate.Value.AddDays(index)
				});
				index++;
			}

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 字体尺寸
		/// </summary>
		/// <returns></returns>
		public JsonResult GetFontSize()
		{
			var result = new List<Dictionary<string, string>>();

			for (int index = 8; index <= 50; index++)
			{
				Dictionary<string, string> map = new Dictionary<string, string>();
				map.Add("Id", index + "px");
				map.Add("Name", index + "px");
				result.Add(map);
			}

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}
		#endregion

		#region 图像显示
		public async Task<ActionResult> HeadImg(string id)
		{
			var result = await DbContext.SysUserMaster.AsNoTracking().FirstOrDefaultAsync(x => x.ID == id);

			if (result != null && !string.IsNullOrEmpty(result.HeadImg))
			{
				return File(result.HeadImg, Application.Octet, Path.GetFileName(result.HeadImg));
			}
			else
			{
				if (result.Gender)
				{
					return File("~/Images/muser.png", Application.Octet, Path.GetFileName("~/Images/muser.png"));
				}
				else
				{
					return File("~/Images/wuser.png", Application.Octet, Path.GetFileName("~/Images/wuser.png"));
				}
			}
		}

		public async Task<ActionResult> QrCodeImg(string id)
		{
			var result = await DbContext.ConferenceAttendenceInfo.AsNoTracking().FirstOrDefaultAsync(x => x.ID == id);

			if (result != null && !string.IsNullOrEmpty(result.QRCode))
			{
				return File(result.QRCode, Application.Octet, Path.GetFileName(result.QRCode));
			}
			else
			{
				return File("~/Images/ConferenceNoPic.png", Application.Octet, Path.GetFileName("~/Images/ConferenceNoPic.png"));
			}
		}

		public async Task<ActionResult> BarCodeImg(string id)
		{
			var result = await DbContext.ConferenceAttendenceInfo.AsNoTracking().FirstOrDefaultAsync(x => x.ID == id);

			if (result != null && !string.IsNullOrEmpty(result.BarCode))
			{
				return File(result.BarCode, Application.Octet, Path.GetFileName(result.BarCode));
			}
			else
			{
				return File("~/Images/ConferenceNoPic.png", Application.Octet, Path.GetFileName("~/Images/ConferenceNoPic.png"));
			}
		}

		public async Task<ActionResult> ConferenceImg(string id)
		{
			var result = await DbContext.ConferenceMaster.AsNoTracking().FirstOrDefaultAsync(x => x.ID == id);

			if (result != null && !string.IsNullOrEmpty(result.PicForPC))
			{
				return File(result.PicForPC, Application.Octet, Path.GetFileName(result.PicForPC));
			}
			else
			{
				return File("~/Images/ConferenceNoPic.png", Application.Octet, Path.GetFileName("~/Images/ConferenceNoPic.png"));
			}
		}

		public async Task<ActionResult> ConferenceBannerImg(string id)
		{
			var result = await DbContext.ConferenceMaster.AsNoTracking().FirstOrDefaultAsync(x => x.ID == id);

			if (result != null && !string.IsNullOrEmpty(result.BannerUrl))
			{
				return File(result.BannerUrl, Application.Octet, Path.GetFileName(result.BannerUrl));
			}
			else
			{
				return File("~/Images/DefaultBannerImg.jpg", Application.Octet, Path.GetFileName("~/Images/DefaultBannerImg.jpg"));
			}
		}

		public async Task<ActionResult> ConferenceBackgroundImg(string id)
		{
			var result = await DbContext.ConferenceMaster.AsNoTracking().FirstOrDefaultAsync(x => x.ID == id);

			if (result != null && !string.IsNullOrEmpty(result.PicForBackground))
			{
				return File(result.PicForBackground, Application.Octet, Path.GetFileName(result.PicForBackground));
			}
			else
			{
				return File("~/Images/DefaultBackground.jpg", Application.Octet, Path.GetFileName("~/Images/DefaultBackground.jpg"));
			}
		}

		public async Task<ActionResult> BannerImg(string id)
		{
			var result = await DbContext.NewsInfo.AsNoTracking().FirstOrDefaultAsync(x => x.ID == id);

			if (result != null && !string.IsNullOrEmpty(result.MainPic))
			{
				return File(result.MainPic, Application.Octet, Path.GetFileName(result.MainPic));
			}
			else
			{
				return File("~/Images/DefaultBannerImg.jpg", Application.Octet, Path.GetFileName("~/Images/DefaultBannerImg.jpg"));
			}
		}

		public async Task<ActionResult> NewsSimpleImg(string id)
		{
			var result = await DbContext.NewsInfo.AsNoTracking().FirstOrDefaultAsync(x => x.ID == id);

			if (result != null && !string.IsNullOrEmpty(result.SimplePic))
			{
				return File(result.SimplePic, Application.Octet, Path.GetFileName(result.SimplePic));
			}
			else
			{
				return File("~/Images/ConferenceNoPic.png", Application.Octet, Path.GetFileName("~/Images/ConferenceNoPic.png"));
			}
		}

		public async Task<ActionResult> NewsMainImg(string id)
		{
			var newsInfo = await DbContext.NewsInfo.AsNoTracking().FirstOrDefaultAsync(x => x.ID == id);

			if (newsInfo != null && !string.IsNullOrEmpty(newsInfo.MainPic))
			{
				return File(newsInfo.MainPic, Application.Octet, Path.GetFileName(newsInfo.MainPic));
			}
			else
			{
				return File("~/Images/ConferenceNoPic.png", Application.Octet, Path.GetFileName("~/Images/ConferenceNoPic.png"));
			}
		}

		public async Task<ActionResult> GetModelImg(string key)
		{
			var model = await DbContext.SysConferenceModelMaster.AsNoTracking().FirstOrDefaultAsync(x => x.ModelKey == key);

			if (model != null && !string.IsNullOrEmpty(model.ModelPic))
			{
				return File(model.ModelPic, Application.Octet, Path.GetFileName(model.ModelPic));
			}
			else
			{
				return File("~/Images/NoConference.jpg", Application.Octet, Path.GetFileName("~/Images/NoConference.jpg"));
			}
		}
		#endregion

		#region 会议相关
		/// <summary>
		/// 检验会议昵称
		/// </summary>
		/// <returns></returns>
		public async Task<JsonResult> CheckConference(string nickName)
		{
			var result = await DbContext.ConferenceMaster.AsNoTracking()
					.FirstOrDefaultAsync(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceNickName == nickName);

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		public async Task<JsonCamelCaseResult> GetConferenceData(string id)
		{
			var data = await DbContext.ConferenceMaster.AsNoTracking().FirstOrDefaultAsync(x => x.ID == id);

			if (data != null)
			{
				var result = new
				{
					ConferenceName = data.ConferenceName,
					ConferenceNickName = data.ConferenceNickName,
					Introduction = data.Introduction,
					ConferenceStartDate = data.ConferenceStartDate,
					ConferenceEndDate = data.ConferenceEndDate,
					ContributeStartDate = data.ContributeStartDate,
					ContributeEndDate = data.ContributeEndDate,
					RegisterStartDate = data.RegisterStartDate,
					RegisterEndDate = data.RegisterEndDate,
					AllowContribute = data.ContributeStartDate.Value <= DateTime.Now && data.ContributeEndDate.Value >= DateTime.Now ? true : false,
					AllowRegister = data.RegisterStartDate.Value <= DateTime.Now && data.RegisterEndDate.Value >= DateTime.Now ? true : false,
					BetweenDays = (data.ConferenceStartDate.Value - DateTime.Now).Days,
					AllowEntry = data.ConferenceStartDate.Value <= DateTime.Now && data.ConferenceEndDate.Value >= DateTime.Now ? true : false,
					PicForPC = data.PicForPC,
					HasContribute = DbContext.ConferenceFunctionMaster.AsNoTracking()
						.Any(e => e.ConferenceId == data.ID &&
							e.Status == ConstValues.Status.正常 &&
							e.FunctionId == ConstValues.FunctionId.ConferenceContributeInfo),
					HasRegister = DbContext.ConferenceFunctionMaster.AsNoTracking()
						.Any(e => e.ConferenceId == data.ID &&
							e.Status == ConstValues.Status.正常 &&
							e.FunctionId == ConstValues.FunctionId.ConferenceAttendenceInfo),
					AllowHotel = DbContext.ConferenceFunctionMaster.AsNoTracking()
						.Any(e => e.ConferenceId == data.ID &&
							e.Status == ConstValues.Status.正常 &&
							e.FunctionId == ConstValues.FunctionId.ConferenceHotelEdit),
					AllowTraffic = DbContext.ConferenceFunctionMaster.AsNoTracking()
						.Any(e => e.ConferenceId == data.ID &&
							e.Status == ConstValues.Status.正常 &&
							e.FunctionId == ConstValues.FunctionId.ConferenceTraffic),
					HasHotel = DbContext.HotelMaster.AsNoTracking().FirstOrDefault(y => y.ConferenceId == data.ID && y.Status == ConstValues.Status.正常) == null ? false : true,
					HasTraffic = DbContext.TrafficMaster.AsNoTracking().FirstOrDefault(y => y.ConferenceId == data.ID && y.Status == ConstValues.Status.正常) == null ? false : true,
				};

				return JsonCamelCase(Utility.CreateSuccessJsonResult(ConstValues.AjaxSuccessResult, result),
						JsonRequestBehavior.AllowGet);
			}
			else
			{
				string errorMessage = Resources.MsgRecordNotExist;
				return JsonCamelCase(Utility.CreateFailJsonResult(errorMessage),
						JsonRequestBehavior.AllowGet);
			}
		}

		//一级菜单
		public async Task<JsonCamelCaseResult> GetLevelOneMenu(string id)
		{
			var sql = DbContext.MenuMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == id &&
						x.ParentId == string.Empty)
					.OrderBy(x => x.Sort)
					.ThenByDescending(x => x.CreateDate);

			var sqlResult = await sql.ToListAsync();

			var result = sqlResult.Select(x => new
			{
				Id = x.ID,
				MenuName = x.MenuName,
				Link = x.Link
			});

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		//二级菜单
		public async Task<JsonCamelCaseResult> GetLevelTwoMenu(string id, string menuId)
		{
			var sql = DbContext.MenuMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == id &&
						x.ParentId == menuId)
					.OrderBy(x => x.Sort)
					.ThenByDescending(x => x.CreateDate);

			var sqlResult = await sql.ToListAsync();

			var result = sqlResult.Select(x => new
			{
				Id = x.ID,
				MenuName = x.MenuName,
				Link = x.Link,
				MenuId = menuId
			});

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		//消息
		public async Task<JsonCamelCaseResult> GetNews(string id, string newslistId)
		{
			var sql = DbContext.NewsInfo.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == id &&
						x.NewsListId == newslistId)
					.OrderByDescending(x => x.Stick).
					ThenByDescending(x => x.Sort).
					ThenBy(x => x.CreateDate);

			var sqlResult = await sql.ToListAsync();

			var newsList = await DbContext.NewsListInfo.AsNoTracking()
					.FirstOrDefaultAsync(x => x.ID == newslistId &&
						x.ConferenceId == id);

			var result = sqlResult.Select(x => new
			{
				Id = x.ID,
				Link = !string.IsNullOrEmpty(x.Link) ? x.Link : ConstValues.SystemWeb + "/MeetingNewsInfo/Index/" + x.ID,
				NewsTitle = x.NewsTitle,
				Abstract = x.Abstract,
				MainText = x.MainText,
				CreateDate = x.CreateDate.Value.ToString("yyyy-MM-dd"),
				SimplePic = x.SimplePic,
				NewsListId = newslistId,
				NewsStyle = newsList.NewsStyle
			});

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}
		#endregion

		#region 投稿相关
		/// <summary>
		/// 获取稿件详细信息
		/// </summary>
		/// <param name="id"></param>
		/// <returns></returns>
		public async Task<JsonCamelCaseResult> GetContributeInfo(string id)
		{
			var sql = from contribute in DbContext.ConferenceContributeInfo.AsNoTracking().Where(x => x.ID == id)
				  join conference in DbContext.ConferenceMaster.AsNoTracking().Where(x => x.Status == ConstValues.Status.正常)
				  on contribute.ConferenceId equals conference.ID
				  join report in DbContext.ReportMaster.AsNoTracking().Where(x => x.Status == ConstValues.Status.正常)
				  on contribute.ReportId equals report.ID into reports
				  from report in reports.DefaultIfEmpty()
				  join essay in DbContext.EssayMaster.AsNoTracking().Where(x => x.Status == ConstValues.Status.正常)
				  on contribute.EssayId equals essay.ID into essays
				  from essay in essays.DefaultIfEmpty()
				  join topic in DbContext.TopicMaster.AsNoTracking().Where(x => x.Status == ConstValues.Status.正常)
				  on contribute.TopicId equals topic.ID into topics
				  from topic in topics.DefaultIfEmpty()
				  select new
				  {
					  ID = contribute.ID,
					  EssayTitle = contribute.EssayTitle,
					  Abstract = contribute.Abstract,
					  Keyword = contribute.Keyword,
					  TopicId = contribute.TopicId,
					  TopicName = topic.TopicName,
					  EssayTypeName = essay.EssayType,
					  ReportId = contribute.ReportId,
					  ReportType = report.ReportType,
					  ProgramAbstract = contribute.ProgramAbstract,
					  AbstractFile = contribute.AbstractFile,
					  SupplementaryFile = contribute.SupplementaryFile,
					  Remark = contribute.Remark,
					  ContributationStatus = contribute.ContributationStatus,
					  IsReview = conference.IsReview,
				  };

			var sqlResult = await sql.FirstOrDefaultAsync();

			if (sqlResult != null)
			{
				var strAuthor = Utility.GetAuthorFormat(id);

				var awardsList = DbContext.ProfileAwardsInfo.AsNoTracking()
					.Where(x => x.ContributeId == id)
					.Join(DbContext.AwardsMaster.AsNoTracking().Where(x => x.Status == ConstValues.Status.正常),
						info => info.AwardsId,
						master => master.ID,
						(info, master) => new
						{
							AwardsName = master.AwardsName
						})
					.OrderBy(x => x.AwardsName)
					.Select(x => x.AwardsName)
					.ToList();

				var strAwards = string.Join(ConstValues.strSemicolon + ConstValues.strSpace, awardsList);

				var finalAdvantage = string.Empty;
				if (sqlResult.IsReview)
				{
					var finalReview = await DbContext.ReviewInfo.AsNoTracking()
							.Where(x => x.ContributeId == id && x.IsFinalReview == true)
							.FirstOrDefaultAsync();

					finalAdvantage = finalReview?.Advantage;
				}

				var result = new
				{
					ContributeId = sqlResult.ID,
					EssayTitle = sqlResult.EssayTitle,
					Author = strAuthor[0],
					Affiliation = strAuthor[1],
					Abstract = sqlResult.Abstract,
					Keyword = !string.IsNullOrEmpty(sqlResult.Keyword) ? sqlResult.Keyword : string.Empty,
					TopicId = sqlResult.TopicId,
					TopicName = !string.IsNullOrEmpty(sqlResult.TopicName) ? sqlResult.TopicName : string.Empty,
					EssayTypeName = !string.IsNullOrEmpty(sqlResult.EssayTypeName) ? sqlResult.EssayTypeName : string.Empty,
					ReportId = sqlResult.ReportId,
					ReportType = !string.IsNullOrEmpty(sqlResult.ReportType) ? sqlResult.ReportType : string.Empty,
					ProgramAbstract = sqlResult.ProgramAbstract,
					AbstractFile = Path.GetFileName(sqlResult.AbstractFile),
					SupplementaryFile = Path.GetFileName(sqlResult.SupplementaryFile),
					Awards = strAwards,
					Remark = !string.IsNullOrEmpty(sqlResult.Remark) ? sqlResult.Remark : string.Empty,
					ContributationStatus = sqlResult.ContributationStatus,
					AbstractFilePath = string.IsNullOrEmpty(sqlResult.AbstractFile) ? string.Empty :
							ConstValues.SystemWeb + sqlResult.AbstractFile.Replace(ConstValues.strWave, string.Empty),
					SupplementaryFilePath = string.IsNullOrEmpty(sqlResult.SupplementaryFile) ? string.Empty :
							ConstValues.SystemWeb + sqlResult.SupplementaryFile.Replace(ConstValues.strWave, string.Empty),
					IsReview = sqlResult.IsReview,
					Advantage = finalAdvantage
				};

				return JsonCamelCase(Utility.CreateSuccessJsonResult(ConstValues.AjaxSuccessResult, result),
						JsonRequestBehavior.AllowGet);
			}
			else
			{
				return JsonCamelCase(Utility.CreateFailJsonResult(Resources.MsgRecordNotExist),
						JsonRequestBehavior.AllowGet);
			}
		}

		/// <summary>
		/// 获取初审结果
		/// </summary>
		/// <param name="id"></param>
		/// <param name="userId"></param>
		/// <returns></returns>
		public async Task<JsonCamelCaseResult> GetJuniorResult(string id, string userId)
		{
			var isJunior = await DbContext.ReviewInfo.AsNoTracking()
					.AnyAsync(x => x.ContributeId == id && x.IsFinalReview == false && x.UserId == userId);

			var sql = from reviewInfo in DbContext.ReviewInfo.AsNoTracking()
						.Where(x => x.ContributeId == id && x.IsFinalReview == false &&
							(isJunior ? x.UserId == userId : true))
				  join user in DbContext.SysUserMaster.AsNoTracking()
				  on reviewInfo.UserId equals user.ID
				  select new
				  {
					  ID = reviewInfo.ID,
					  UserId = reviewInfo.UserId,
					  Quality = reviewInfo.Quality,
					  Evaluation = reviewInfo.Evaluation,
					  Remark = reviewInfo.Remark,
					  Advantage = reviewInfo.Advantage,
					  Defect = reviewInfo.Defect,
					  Others = reviewInfo.Others,
					  Result = reviewInfo.Result,
					  UserName = user.UserName
				  };

			var sqlResult = await sql.ToListAsync();

			var result = sqlResult.Select(x => new
			{
				Id = x.ID,
				UserId = x.UserId,
				Quality = x.Quality,
				Evaluation = x.Evaluation,
				Remark = !string.IsNullOrEmpty(x.Remark) ? x.Remark : string.Empty,
				Advantage = x.Advantage,
				Defect = x.Defect,
				Others = x.Others,
				Result = x.Result,
				UserName = x.UserName
			});

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 获取作者Grid
		/// </summary>
		/// <param name="id"></param>
		/// <returns></returns>
		public async Task<JsonCamelCaseResult> GetAuthorList(string id)
		{
			var sql = from authorInfo in DbContext.AuthorInfo.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 && x.ContributeId == id)
				  join conferenceMaster in DbContext.ConferenceMaster.AsNoTracking()
					on authorInfo.ConferenceId equals conferenceMaster.ID
				  join countryMaster in DbContext.LocationMaster.AsNoTracking()
					  on authorInfo.Country equals countryMaster.ID into t1
				  from country in t1.DefaultIfEmpty()
				  join stateMaster in DbContext.LocationMaster.AsNoTracking()
					  on authorInfo.State equals stateMaster.ID into t2
				  from state in t2.DefaultIfEmpty()
				  join cityMaster in DbContext.LocationMaster.AsNoTracking()
					  on authorInfo.City equals cityMaster.ID into t3
				  from city in t3.DefaultIfEmpty()
				  orderby authorInfo.Sort, authorInfo.CreateDate, authorInfo.FullName
				  select new AuthorModel
				  {
					  Sort = authorInfo.Sort,
					  Id = authorInfo.ID,
					  FullName = authorInfo.FullName,
					  Mail = authorInfo.Mail,
					  Department = authorInfo.Department,
					  Status = authorInfo.Status,
					  IsContactAuthor = authorInfo.IsContactAuthor,
					  IsPresenter = authorInfo.IsPresenter,
					  Remark = authorInfo.Remark,

					  FamilyName = authorInfo.FamilyName,
					  FirstName = authorInfo.FirstName,
					  CountryName = conferenceMaster.IsInternational ? country.NameEn : country.Name,
					  StateName = conferenceMaster.IsInternational ? state.NameEn : state.Name,
					  CityName = conferenceMaster.IsInternational ? city.NameEn : city.Name,
					  Address = authorInfo.Address,
					  ZipCode = authorInfo.ZipCode,
					  Mobile = authorInfo.Mobile,
					  CcMail = authorInfo.CcMail,
					  SelfIntroduction = authorInfo.SelfIntroduction,

					  ConferenceId = authorInfo.ConferenceId,
					  ContributeId = authorInfo.ContributeId
				  };

			var sqlResult = await sql.ToListAsync();

			sqlResult.ForEach(y =>
			{
				var affiliationList = DbContext.AffiliationInfo.AsNoTracking()
						.Where(x => x.Status == ConstValues.Status.正常 &&
							x.ConferenceId == y.ConferenceId &&
							x.ContributeId == y.ContributeId &&
							x.Mail == y.Mail)
						.OrderBy(x => x.Sort)
						.ThenBy(x => x.Affiliation)
						.Select(x => x.Affiliation)
						.ToList();

				y.Affiliation = affiliationList.Count > 0 ? string.Join(ConstValues.strSemicolon, affiliationList) : string.Empty;
			});

			return JsonCamelCase(sqlResult, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 获取作者单条
		/// </summary>
		/// <param name="id"></param>
		/// <returns></returns>
		public async Task<JsonCamelCaseResult> GetEditAuthor(string id)
		{
			var authorInfo = await DbContext.AuthorInfo.AsNoTracking().FirstOrDefaultAsync(x => x.ID == id);

			var affiliationList = await DbContext.AffiliationInfo.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == authorInfo.ConferenceId &&
						x.ContributeId == authorInfo.ContributeId &&
						x.Mail == authorInfo.Mail)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.Affiliation)
					.Select(x => x.Affiliation)
					.ToListAsync();
			var countryList = await DbContext.AffiliationInfo.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == authorInfo.ConferenceId &&
						x.ContributeId == authorInfo.ContributeId &&
						x.Mail == authorInfo.Mail)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.Affiliation)
					.Select(x => x.Country)
					.ToListAsync();
			if (authorInfo != null)
			{
				var result = new AuthorModel
				{
					FamilyName = authorInfo.FamilyName,
					FirstName = authorInfo.FirstName,
					FullName = authorInfo.FullName,
					Department = authorInfo.Department,
					Country = authorInfo.Country,
					State = authorInfo.State,
					City = authorInfo.City,
					Address = authorInfo.Address,
					ZipCode = authorInfo.ZipCode,
					Mobile = authorInfo.Mobile,
					Mail = authorInfo.Mail,
					CcMail = authorInfo.CcMail,
					SelfIntroduction = authorInfo.SelfIntroduction,
					Sort = authorInfo.Sort,
					Status = authorInfo.Status,
					Remark = authorInfo.Remark
				};

				result.Affiliation0 = affiliationList.Count > 0 ? affiliationList[0] : string.Empty;
				result.Affiliation1 = affiliationList.Count > 1 ? affiliationList[1] : string.Empty;
				result.Affiliation2 = affiliationList.Count > 2 ? affiliationList[2] : string.Empty;
				result.Affiliation3 = affiliationList.Count > 3 ? affiliationList[3] : string.Empty;
				result.Affiliation4 = affiliationList.Count > 4 ? affiliationList[4] : string.Empty;
				result.Affiliation5 = affiliationList.Count > 5 ? affiliationList[5] : string.Empty;
				result.Affiliation6 = affiliationList.Count > 6 ? affiliationList[6] : string.Empty;
				result.Affiliation7 = affiliationList.Count > 7 ? affiliationList[7] : string.Empty;
				result.Affiliation8 = affiliationList.Count > 8 ? affiliationList[8] : string.Empty;
				result.Affiliation9 = affiliationList.Count > 9 ? affiliationList[9] : string.Empty;

				result.Country0 = countryList.Count > 0 ? countryList[0] : 0;
				result.Country1 = countryList.Count > 1 ? countryList[1] : 0;
				result.Country2 = countryList.Count > 2 ? countryList[2] : 0;
				result.Country3 = countryList.Count > 3 ? countryList[3] : 0;
				result.Country4 = countryList.Count > 4 ? countryList[4] : 0;
				result.Country5 = countryList.Count > 5 ? countryList[5] : 0;
				result.Country6 = countryList.Count > 6 ? countryList[6] : 0;
				result.Country7 = countryList.Count > 7 ? countryList[7] : 0;
				result.Country8 = countryList.Count > 8 ? countryList[8] : 0;
				result.Country9 = countryList.Count > 9 ? countryList[9] : 0;

				return JsonCamelCase(Utility.CreateSuccessJsonResult(string.Empty, result),
						JsonRequestBehavior.AllowGet);
			}
			else
			{
				return JsonCamelCase(Utility.CreateFailJsonResult(Resources.MsgRecordNotExist),
						JsonRequestBehavior.AllowGet);
			}
		}

		/// <summary>
		/// 获取投稿所有项目
		/// </summary>
		/// <param name="conferenceId"></param>
		/// <returns></returns>
		public async Task<JsonCamelCaseResult> GetCurrentPageItemContribute(string conferenceId)
		{
			var result = await DbContext.ConferenceContributeForm.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == conferenceId &&
						x.Key != ConstValues.参会投稿表单.同期活动)
					.OrderBy(x => x.DisplayPage)
					.ThenBy(x => x.Sort)
					.ThenBy(x => x.DisplayName)
					.ToListAsync();

			return JsonCamelCase(Utility.CreateSuccessJsonResult(string.Empty, result),
					JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 获取投稿所有值
		/// </summary>
		/// <param name="id"></param>
		/// <returns></returns>
		public async Task<JsonCamelCaseResult> GetCurrentPageValueContribute(string id)
		{
			var sqlResult = await DbContext.ConferenceContributeInfo.AsNoTracking()
					.Where(x => x.ID == id)
					.Join(DbContext.ConferenceMaster.AsNoTracking()
						.Where(x => x.Status == ConstValues.Status.正常),
						info => info.ConferenceId,
						master => master.ID,
						(info, master) => new
						{
							EssayTitle = info.EssayTitle,
							Keyword = info.Keyword,
							ProgramAbstract = info.ProgramAbstract,
							Abstract = info.Abstract,
							AbstractFile = info.AbstractFile,
							SupplementaryFile = info.SupplementaryFile,
							TopicId = info.TopicId,
							EssayId = info.EssayId,
							ReportId = info.ReportId,
							OcisId = info.OcisId,
							JournalId = info.JournalId,
							Language = master.IsInternational
						}).FirstOrDefaultAsync();

			if (sqlResult == null)
			{
				return JsonCamelCase(Utility.CreateFailJsonResult(),
						JsonRequestBehavior.AllowGet);
			}

			var result = new
			{
				EssayTitle = sqlResult.EssayTitle,
				Keyword = sqlResult.Keyword,
				ProgramAbstract = sqlResult.ProgramAbstract,
				Abstract = sqlResult.Abstract,
				AbstractFile = Path.GetFileName(sqlResult.AbstractFile),
				SupplementaryFile = Path.GetFileName(sqlResult.SupplementaryFile),
				TopicId = sqlResult.TopicId,
				EssayId = sqlResult.EssayId,
				ReportId = sqlResult.ReportId,
				OcisId = sqlResult.OcisId,
				JournalId = sqlResult.JournalId,
				Language = sqlResult.Language ? ConstValues.Language.En : ConstValues.Language.Cn
			};

			return JsonCamelCase(Utility.CreateSuccessJsonResult(string.Empty, result),
					JsonRequestBehavior.AllowGet);
		}

		[Route("DownloadContributeFile/{id}/{type}")]
		public async Task<ActionResult> DownloadContributeFile(string id, string type)
		{
			var result = await DbContext.ConferenceContributeInfo.AsNoTracking()
					    .FirstOrDefaultAsync(x => x.ID == id);
			if (result != null)
			{
				switch (type)
				{
					case ConstValues.FileType.Abstract:
						if (!string.IsNullOrWhiteSpace(result.AbstractFile))
						{
							return File(result.AbstractFile, Application.Octet, result.ID + "_Abstract" + Path.GetExtension(result.AbstractFile));
						}
						break;
					case ConstValues.FileType.Supplementary:
						if (!string.IsNullOrWhiteSpace(result.SupplementaryFile))
						{
							return File(result.SupplementaryFile, Application.Octet, result.ID + "_Supplementary" + Path.GetExtension(result.SupplementaryFile));
						}
						break;
				}
			}

			return new HttpStatusCodeResult(HttpStatusCode.NotFound);
		}

		/// <summary>
		/// 获取评优活动列表
		/// </summary>
		/// <param name="conferenceId"></param>
		/// <returns></returns>
		public async Task<JsonCamelCaseResult> GetAwardsMasterList(string conferenceId)
		{
			var result = await DbContext.AwardsMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == conferenceId)
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.AwardsName)
					.ToListAsync();

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}

		/// <summary>
		/// 获取评优活动
		/// </summary>
		/// <param name="conferenceId"></param>
		/// <param name="contributeId"></param>
		/// <returns></returns>
		public async Task<JsonCamelCaseResult> GetAwardsList(string conferenceId, string contributeId, string userName)
		{
			var sql = DbContext.AwardsMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 && x.ConferenceId == conferenceId)
					.GroupJoin(DbContext.ProfileAwardsInfo.AsNoTracking()
						.Where(x => x.ContributeId == contributeId &&
							x.UserName == userName),
						awardsMaster => awardsMaster.ID,
						awardsInfo => awardsInfo.AwardsId,
						(awardsMaster, awardsInfo) => new
						{
							ID = awardsMaster.ID,
							AwardsName = awardsMaster.AwardsName,
							AwardsContent = awardsMaster.AwardsContent,
							Link = awardsMaster.Link,
							AwardsId = awardsInfo.FirstOrDefault().ID,
							Sort = awardsMaster.Sort
						})
					.OrderBy(x => x.Sort)
					.ThenBy(x => x.AwardsName);

			var result = await sql.ToListAsync();

			return JsonCamelCase(result, JsonRequestBehavior.AllowGet);
		}
		#endregion

		#region 参会注册相关
		/// <summary>
		/// 获取会议币种
		/// </summary>
		/// <param name="conferenceId"></param>
		/// <returns></returns>
		public async Task<JsonResult> GetCurrency(string conferenceId)
		{
			var sql = DbContext.FeeAttendenceMaster.AsNoTracking()
					.Where(x => x.ConferenceId == conferenceId &&
						x.Status == ConstValues.Status.正常)
						.GroupBy(x => x.Currency).Select(x => x.Key)
					.Union(DbContext.FeeMealMaster.AsNoTracking()
						.Where(x => x.ConferenceId == conferenceId &&
							x.Status == ConstValues.Status.正常)
						.GroupBy(x => x.Currency).Select(x => x.Key))
					.Union(DbContext.FeeOtherMaster.AsNoTracking()
						.Where(x => x.ConferenceId == conferenceId &&
							x.Status == ConstValues.Status.正常)
						.GroupBy(x => x.Currency).Select(x => x.Key))
					.Union(DbContext.FeePageMaster.AsNoTracking()
						.Where(x => x.ConferenceId == conferenceId &&
							x.Status == ConstValues.Status.正常)
						.GroupBy(x => x.Currency).Select(x => x.Key))
					.Union(DbContext.HotelMaster.AsNoTracking()
						.Where(x => x.ConferenceId == conferenceId &&
							x.Status == ConstValues.Status.正常)
						.Join(DbContext.RoomMaster.AsNoTracking()
							.Where(x => x.Status == ConstValues.Status.正常),
							hotel => hotel.ID,
							room => room.HotelId,
							(hotel, room) => new
							{
								Currency = room.Currency
							}
						)
						.GroupBy(x => x.Currency).Select(x => x.Key))
					.Union(DbContext.ConcurrentEventMaster.AsNoTracking()
						.Where(x => x.ConferenceId == conferenceId &&
							x.Status == ConstValues.Status.正常)
						.Join(DbContext.FeeConcurrentEventMaster.AsNoTracking()
							.Where(x => x.Status == ConstValues.Status.正常),
							conevent => conevent.ID,
							eventFee => eventFee.ConcurrentEventId,
							(conevent, eventFee) => new
							{
								Currency = eventFee.Currency
							}
						)
						.GroupBy(x => x.Currency).Select(x => x.Key));

			var sqlResult = await sql.ToListAsync();

			var result = sqlResult.Select(x => new
			{
				Currency = x.ToString()
			});

			return JsonCamelCase(Utility.CreateSuccessJsonResult(string.Empty, result),
					JsonRequestBehavior.AllowGet);
		}

		public async Task<JsonCamelCaseResult> GetCurrentPageItem(string conferenceId)
		{
			var result = await DbContext.ConferenceAttendenceForm.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == conferenceId)
					.OrderBy(x => x.DisplayPage)
					.ThenBy(x => x.Sort)
					.ThenBy(x => x.DisplayName)
					.ToListAsync();

			return JsonCamelCase(Utility.CreateSuccessJsonResult(string.Empty, result),
					JsonRequestBehavior.AllowGet);
		}

		public async Task<JsonCamelCaseResult> GetCurrentPageValue(string id)
		{
			var sql = from info in DbContext.ConferenceAttendenceInfo.AsNoTracking().Where(x => x.ID == id)
				  join profilePaymentInfo in DbContext.ProfilePaymentInfo.AsNoTracking().Where(x => x.FeeType == ConstValues.FeeType.版面费)
					on info.ID equals profilePaymentInfo.AttendenceId into t1
				  from pageFee in t1.DefaultIfEmpty()
				  join profilePaymentInfo in DbContext.ProfilePaymentInfo.AsNoTracking().Where(x => x.FeeType == ConstValues.FeeType.参会费)
					on info.ID equals profilePaymentInfo.AttendenceId into t2
				  from attendenceFee in t2.DefaultIfEmpty()
				  join profilePaymentInfo in DbContext.ProfilePaymentInfo.AsNoTracking().Where(x => x.FeeType == ConstValues.FeeType.餐费)
					on info.ID equals profilePaymentInfo.AttendenceId into t3
				  from mealFee in t3.DefaultIfEmpty()
				  join conferenceMaster in DbContext.ConferenceMaster.AsNoTracking()
				       on info.ConferenceId equals conferenceMaster.ID
				  select new
				  {
					  ID = info.ID,
					  ConferenceId = info.ConferenceId,
					  Mail = info.Mail,
					  FamilyName = info.FamilyName,
					  FirstName = info.FirstName,
					  FullName = info.FullName,
					  Gender = info.Gender,
					  Title = info.Title,
					  Degree = info.Degree,
					  Job = info.Job,
					  Affiliation = info.Affiliation,
					  Department = info.Department,
					  Country = info.Country,
					  State = info.StateStr,
					  City = info.CityStr,
					  Address = info.Address,
					  ZipCode = info.ZipCode,
					  Telephone = info.Telephone,
					  Mobile = info.Mobile,
					  CardId = info.CardId,
					  AttendenceIdentityId = info.AttendenceIdentityId,
					  AttendenceFeeId = attendenceFee.FeeId,
					  PageFeeId = pageFee.FeeId,
					  MealFeeId = mealFee.FeeId,
					  InvoiceTitle = info.InvoiceTitle,
					  TaxNum = info.TaxNum,
					  AddressAndTel = info.AddressAndTel,
					  Bank = info.Bank,
					  BankAccount = info.BankAccount,
					  InvoiceId = info.InvoiceId,
					  FavouriteTopicId = info.FavouriteTopicId,
					  Customize1 = info.Customize1,
					  Customize2 = info.Customize2,
					  Customize3 = info.Customize3,
					  Customize4 = info.Customize4,
					  Customize5 = info.Customize5,
					  Customize6 = info.Customize6,
					  Customize7 = info.Customize7,
					  Customize8 = info.Customize8,
					  Customize9 = info.Customize9,
					  Customize10 = info.Customize10,
					  PaymentTypeId = info.PaymentTypeId,
					  Sort = info.Sort,
					  Remark = info.Remark,
					  Currency = info.Currency,
					  HasPaid = info.HasPaid,
					  HasInvoiced = info.HasInvoiced,
					  IsInternational = conferenceMaster.IsInternational,
				  };

			var sqlResult = await sql.ToListAsync();

			var eventPaymentInfo = await DbContext.ProfilePaymentInfo.AsNoTracking()
					.Where(x => x.FeeType == ConstValues.FeeType.同期活动费 && x.AttendenceId == id)
					.ToListAsync();
			var ConcurrentEventList = string.Empty;
			var ConcurrentEventCount = string.Empty;
			eventPaymentInfo.ForEach(x =>
			{
				if (string.IsNullOrEmpty(ConcurrentEventList))
				{
					ConcurrentEventList += DbContext.FeeConcurrentEventMaster.FirstOrDefault(y => y.ID == x.FeeId)?.ConcurrentEventId;
					ConcurrentEventCount += x.Count.Value.ToString();
				}
				else
				{
					ConcurrentEventList += ConstValues.chrComma + DbContext.FeeConcurrentEventMaster.FirstOrDefault(y => y.ID == x.FeeId)?.ConcurrentEventId;
					ConcurrentEventCount += ConstValues.chrComma + x.Count.Value.ToString();
				}
			});

			var result = sqlResult.Select(x => new
			{
				ID = x.ID,
				ConferenceId = x.ConferenceId,
				Mail = x.Mail,
				FamilyName = x.FamilyName,
				FirstName = x.FirstName,
				FullName = x.FullName,
				Gender = x.Gender,
				Title = x.Title,
				Degree = x.Degree,
				Job = x.Job,
				Affiliation = x.Affiliation,
				Department = x.Department,
				Country = x.Country,
				State = x.State,
				City = x.City,
				Address = x.Address,
				ZipCode = x.ZipCode,
				Telephone = x.Telephone,
				Mobile = x.Mobile,
				CardId = x.CardId,
				AttendenceIdentityId = x.AttendenceIdentityId,
				applyIdentity = Utility.GetApplyIdentity(id),
				AttendenceFeeId = x.AttendenceFeeId,
				PageFeeId = x.PageFeeId,
				MealFeeId = x.MealFeeId,
				InvoiceTitle = x.InvoiceTitle,
				TaxNum = x.TaxNum,
				AddressAndTel = x.AddressAndTel,
				Bank = x.Bank,
				BankAccount = x.BankAccount,
				InvoiceId = x.InvoiceId,
				FavouriteTopic = x.FavouriteTopicId.Split(ConstValues.chrSemicolon),
				Customize1 = x.Customize1,
				Customize2 = x.Customize2,
				Customize3 = x.Customize3,
				Customize4 = x.Customize4,
				Customize5 = x.Customize5,
				Customize6 = x.Customize6,
				Customize7 = x.Customize7,
				Customize8 = x.Customize8,
				Customize9 = x.Customize9,
				Customize10 = x.Customize10,
				ConcurrentEventList = ConcurrentEventList,
				ConcurrentEventCount = ConcurrentEventCount,
				PaymentTypeId = x.PaymentTypeId,
				Currency = x.Currency,
				Sort = x.Sort,
				Remark = x.Remark,
				HasPaid = x.HasPaid,
				HasInvoiced = x.HasInvoiced,
			});

			if (result.Count() > 0)
			{
				return JsonCamelCase(Utility.CreateSuccessJsonResult(string.Empty, result.FirstOrDefault()),
						JsonRequestBehavior.AllowGet);
			}
			else
			{
				return JsonCamelCase(Utility.CreateFailJsonResult(Resources.MsgRecordNotExist),
						JsonRequestBehavior.AllowGet);
			}
		}

		public async Task<JsonCamelCaseResult> GetPersonalData(string id)
		{
			var personal = await DbContext.ConferenceAttendenceInfo.AsNoTracking().FirstOrDefaultAsync(x => x.ID == id);

			if (personal != null)
			{
				var conferenceMaster = await DbContext.ConferenceMaster.AsNoTracking().FirstOrDefaultAsync(x => x.ID == personal.ConferenceId);

				var isBenefit = false;
				if (DateTime.Now >= conferenceMaster.BenefitStartDate && DateTime.Now <= conferenceMaster.BenefitEndDate)
				{
					isBenefit = true;
				}
				var payTypeId = DbContext.ConferencePaymentMaster.AsNoTracking().FirstOrDefault(x => x.ID == personal.PaymentTypeId)?.PayId;
				//查询论文编号
				var essayList = await DbContext.ConferenceContributeInfo.AsNoTracking()
						.Where(x => personal.EssayId.Contains(x.ID.ToString()))
						//.Select(x => x.EssayTitle)
						.ToListAsync();
				List<string> strList = new List<string>();
				essayList.ForEach(x =>
				{
					var reportType = DbContext.ReportMaster.AsNoTracking().FirstOrDefault(y => y.ID == x.ReportId)?.ReportType;
					strList.Add(x.ID + ConstValues.strSpace + ConstValues.strLeftBracket + reportType + ConstValues.strRightBracket);
				});

				var essayArray = strList.ToArray();
				var essay = string.Join(ConstValues.chrSpace + ConstValues.strSemicolon + ConstValues.chrSpace, essayArray);

				//查询报告id
				var reportId = string.Empty;
				var reportList = await DbContext.ScheduleInfo.AsNoTracking().Where(x => personal.EssayId.Contains(x.ID.ToString())).ToListAsync();
				reportList.ForEach(x =>
				{
					if (string.IsNullOrEmpty(reportId))
					{
						reportId += x.ID;
					}
					else
					{
						reportId += ConstValues.chrSpace + ConstValues.chrComma + ConstValues.chrSpace + x.ID;
					}
				});
				//查询费用明细
				var sql = from paymentInfo in DbContext.ProfilePaymentInfo.AsNoTracking().Where(x => x.AttendenceId == id)
					  join attInfo in DbContext.ConferenceAttendenceInfo.AsNoTracking()
						  on paymentInfo.AttendenceId equals attInfo.ID
					  join conferenceMaster2 in DbContext.ConferenceMaster.AsNoTracking()
						  on attInfo.ConferenceId equals conferenceMaster2.ID
					  select new ProfilePayInfoModel
					  {
						  FeeType = paymentInfo.FeeType,
						  FeeId = paymentInfo.FeeId,
						  FeeName = string.Empty,
						  Count = paymentInfo.Count,
						  Currency = paymentInfo.Currency,
						  Fee = paymentInfo.Fee,
						  Discount = paymentInfo.Discount,
						  BenefitEndDate = conferenceMaster2.BenefitEndDate,
						  BenefitStartDate = conferenceMaster2.BenefitStartDate
					  };
				var sqlResult = await sql.ToListAsync();
				sqlResult.ForEach(x =>
				{
					if (x.FeeType == ConstValues.FeeType.餐费)
					{
						x.FeeType = Resources.FeeMeal;
						x.FeeName = DbContext.FeeMealMaster.AsNoTracking().FirstOrDefault(y => y.ID == x.FeeId).FeeName;
					}
					else if (x.FeeType == ConstValues.FeeType.参会费)
					{
						x.FeeType = Resources.FeeAttend;
						x.FeeName = DbContext.FeeAttendenceMaster.AsNoTracking().FirstOrDefault(y => y.ID == x.FeeId).RegisterType;
					}
					else if (x.FeeType == ConstValues.FeeType.版面费)
					{
						x.FeeType = Resources.FeePage;
						x.FeeName = DbContext.FeePageMaster.AsNoTracking().FirstOrDefault(y => y.ID == x.FeeId).FeeName;
					}
					else if (x.FeeType == ConstValues.FeeType.其他费用)
					{
						x.FeeType = Resources.FeeOther;
						x.FeeName = DbContext.FeeOtherMaster.AsNoTracking().FirstOrDefault(y => y.ID == x.FeeId).FeeName;
					}
					else if (x.FeeType == ConstValues.FeeType.同期活动费)
					{
						x.FeeType = Resources.ConferenceFeeEvent;
						var ConcurrentEventId = DbContext.FeeConcurrentEventMaster.AsNoTracking().FirstOrDefault(y => y.ID == x.FeeId)?.ConcurrentEventId;
						x.FeeName = DbContext.ConcurrentEventMaster.AsNoTracking().FirstOrDefault(y => y.ID == ConcurrentEventId)?.EventName;
					}
				});
				List<string> feeDetailList = new List<string>();
				sqlResult.ForEach(x =>
				{
					var detailStr = string.Empty;
					detailStr += x.FeeType;
					detailStr += ConstValues.strSpace;
					detailStr += x.FeeName;
					detailStr += ConstValues.strSpace;
					detailStr += x.Currency;
					detailStr += ConstValues.chrSpace;
					if (isBenefit)
					{
						detailStr += x.Discount;
					}
					else
					{
						detailStr += x.Fee;
					}
					feeDetailList.Add(detailStr);
				});
				var feeDetail = string.Join("\n", feeDetailList);

				//查询支付时间
				var paymentRecord = await DbContext.ProfilePaymentRecord.AsNoTracking().FirstOrDefaultAsync(x => x.AttendenceId == id && x.FeeStatus == true);
				var paymentTime = string.Empty;
				if (paymentRecord != null)
				{
					paymentTime = conferenceMaster.IsInternational ? paymentRecord.CreateDate.Value.ToString("yyyy-MM-dd HH:mm") : paymentRecord.CreateDate.Value.ToString("MM/dd/yyyy HH:mm");
				}

				var result = new
				{
					attendid = personal.ID,
					fullname = personal.FullName,
					affiliation = personal.Affiliation,
					mail = personal.Mail,
					tele = personal.Mobile,
					country = personal.Country == null ? string.Empty : (
							conferenceMaster.IsInternational ?
							DbContext.LocationMaster.AsNoTracking().FirstOrDefault(x => x.ID == personal.Country)?.NameEn :
							DbContext.LocationMaster.AsNoTracking().FirstOrDefault(x => x.ID == personal.Country)?.Name),
					essay = essay,
					address = personal.Address,
					zipCode = personal.ZipCode,
					fee = personal.Currency + ConstValues.strSpace + (isBenefit ? personal.Discount : personal.TotalFee).Value.ToString("N2"),
					payType = conferenceMaster.IsInternational ?
							DbContext.SysPaymentMaster.AsNoTracking().FirstOrDefault(x => x.ID == payTypeId)?.PaymentNameEn :
							DbContext.SysPaymentMaster.AsNoTracking().FirstOrDefault(x => x.ID == payTypeId)?.PaymentName,
					invoiceTitle = personal.InvoiceTitle,
					taxNum = personal.TaxNum,
					addressAndTel = personal.AddressAndTel,
					bank = personal.Bank,
					bankAccount = personal.BankAccount,
					bankAndAccount = personal.Bank + ConstValues.chrSpace + personal.BankAccount,
					invoiceNum = string.IsNullOrEmpty(personal.InvoiceNum) ? string.Empty : personal.InvoiceNum,
					invoiceDetail = DbContext.ConferenceInvoiceMaster.AsNoTracking().FirstOrDefault(x => x.ID == personal.InvoiceId)?.InvoiceDetail,
					arrivalDate = personal.ArrivalDate.HasValue ? (conferenceMaster.IsInternational ?
							personal.ArrivalDate.Value.ToString("MM/dd/yyyy") :
							personal.ArrivalDate.Value.ToString("yyyy-MM-dd")) : null,
					creator = personal.Creator,
					departuralDate = personal.DeparturalDate.HasValue ? (conferenceMaster.IsInternational ?
							personal.DeparturalDate.Value.ToString("MM/dd/yyyy") :
							personal.DeparturalDate.Value.ToString("yyyy-MM-dd")) : null,
					Id = personal.ID,
					arrivalFlight = personal.ArrivalFlight,
					departuralFlight = personal.DeparturalFlight,
					remark = string.IsNullOrEmpty(personal.Remark) ? string.Empty : personal.Remark,
					createDate = personal.CreateDate.HasValue ? (conferenceMaster.IsInternational ?
							personal.CreateDate.Value.ToString("MM/dd/yyyy") :
							personal.CreateDate.Value.ToString("yyyy-MM-dd")) : null,
					attendenceIdentity = DbContext.AttendenceIdentityMaster.AsNoTracking().FirstOrDefault(x => x.ID == personal.AttendenceIdentityId)?.IdentityName,
					paymentHasPay = personal.ActuallyFee.HasValue ? (personal.Currency + ConstValues.strSpace + personal.ActuallyFee.Value.ToString("N2")) : string.Empty,
					hasPaid = personal.HasPaid == true ? Resources.HasPaid : Resources.HasNotPaid,
					feeDetail = feeDetail,
					paymentTime = paymentTime,
					reportId = reportId,
					customize1 = personal.Customize1,
					customize2 = personal.Customize2,
					customize3 = personal.Customize3,
					customize4 = personal.Customize4,
					customize5 = personal.Customize5,
					customize6 = personal.Customize6,
					customize7 = personal.Customize7,
					customize8 = personal.Customize8,
					customize9 = personal.Customize9,
					customize10 = personal.Customize10,
				};

				return JsonCamelCase(Utility.CreateSuccessJsonResult(string.Empty, result),
						JsonRequestBehavior.AllowGet);
			}
			else
			{
				return JsonCamelCase(Utility.CreateFailJsonResult(Resources.MsgRecordNotExist),
						JsonRequestBehavior.AllowGet);
			}
		}

		public async Task<JsonCamelCaseResult> GetConcurrentEvent(string conferenceId, string identity, string currency)
		{
			var result = await DbContext.ConcurrentEventMaster.AsNoTracking()
					.Where(x => x.Status == ConstValues.Status.正常 &&
						x.ConferenceId == conferenceId)
					.OrderBy(x => x.Sort)
					.ToListAsync();

			var newResult = result.Select(x => new
			{
				id = x.ID,
				eventName = x.EventName,
				eventPlace = x.EventPlace,
				eventTime = x.EventTime,
				link = x.Link,
				contact = x.Contact == null ? string.Empty : x.Contact,
				contactPhone = x.ContactPhone == null ? string.Empty : x.ContactPhone,
				fee = Utility.GetFeeAndIdentity(x.ID, x.IsAllIdentity, currency),
				hasEvent = Utility.HasEvent(x.ID, identity, currency),
				number = DbContext.FeeConcurrentEventMaster.AsNoTracking().FirstOrDefault(y => y.ConcurrentEventId == x.ID && y.Currency == currency
						&& (y.AttendenceIdentityId == ConstValues.ApplicableForAll || y.AttendenceIdentityId == identity))?.Number,
				price = DbContext.FeeConcurrentEventMaster.AsNoTracking().FirstOrDefault(y => y.ConcurrentEventId == x.ID && y.Currency == currency
						&& (y.AttendenceIdentityId == ConstValues.ApplicableForAll || y.AttendenceIdentityId == identity))?.Price,
				currency = currency,
			}).ToList();

			return JsonCamelCase(Utility.CreateSuccessJsonResult(string.Empty, newResult),
					JsonRequestBehavior.AllowGet);
		}

		public JsonCamelCaseResult GetCustomizeList(string conferenceId)
		{
			return JsonCamelCase(Utility.CreateSuccessJsonResult(string.Empty, Utility.GetAttendenceCustomizeList(conferenceId)),
					JsonRequestBehavior.AllowGet);
		}
		#endregion

		#region 多语言切换
		[HttpPost]
		public ActionResult SetCulture(string culture)
		{
			// Validate input
			culture = CultureHelper.GetImplementedCulture(culture);
			// Save culture in a cookie
			HttpCookie cookie = Request.Cookies["_culture"];
			if (cookie != null)
			{
				cookie.Expires = DateTime.Now.AddDays(-1);
				cookie = new HttpCookie("_culture");
				cookie.Value = culture;
				cookie.Expires = DateTime.Now.AddYears(1);
			}
			else
			{
				cookie = new HttpCookie("_culture");
				cookie.Value = culture;
				cookie.Expires = DateTime.Now.AddYears(1);
			}
			Response.Cookies.Add(cookie);

			var route = Request.UrlReferrer.AbsolutePath.Split(ConstValues.chrSlash);
			if (route.Count() < 3)
			{
				return RedirectToAction(nameof(HomeController.MainIndex), nameof(HomeController).GetControllerName());
			}

			var controllerName = route[1];
			var actionName = route[2];

			if (ConstValues.PageLogsType_System.Contains(controllerName))
			{
				return RedirectToAction(actionName, controllerName);
			}
			else if (ConstValues.PageLogsType_Conference.Contains(controllerName))
			{
				var conferenceId = route[3];
				return RedirectToAction(actionName, controllerName, new { ConferenceId = conferenceId });
			}
			else if (controllerName == "MeetingMain")
			{
				var nickname = route[3];
				return RedirectToAction(actionName, controllerName, new { name = nickname });
			}
			else if (controllerName == "MeetingNewsList" || controllerName == "MeetingNewsInfo")
			{
				var id = route[3];
				return RedirectToAction(actionName, controllerName, new { id = id });
			}
			else if (controllerName == "MeetingAttendence" || controllerName == "MeetingContribute")
			{
				var conferenceId = Request.UrlReferrer.ToString().Split(ConstValues.chrEquals)[1];
				return RedirectToAction(actionName, controllerName, new { ConferenceId = conferenceId });
			}
			else
			{
				if (controllerName == "Account" && actionName == "SendPasswordMail")
				{
					actionName = "Login";
				}
				return RedirectToAction(actionName, controllerName);
			}
		}
		#endregion
	}
}